package com.example.train.app.service.impl;

import com.example.train.api.dto.EmployeeDTO;
import com.example.train.app.service.IndexService;
import com.example.train.app.service.assembler.EmployeeAssembler;
import com.example.train.domain.entity.Employee;
import com.example.train.domain.repository.IndexRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IndexServiceImpl implements IndexService {

    private final IndexRepository indexRepository;

    public IndexServiceImpl(IndexRepository indexRepository) {
        this.indexRepository = indexRepository;
    }

    @Override
    public String status() {
        return "Server is running......";
    }

    @Override
    public List<Employee> listEmployees(EmployeeDTO employeeDTO) {

        List<Employee> employeeList = indexRepository.findEmployeeByCondition(EmployeeAssembler.toEmployee(employeeDTO));

        return employeeList;
    }


}
